From 3bd7b2a6fb31a3cf379466b08c497552f0c27c0f Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 24 Jun 2015 21:52:23 +0200 Subject: [PATCH] wayland: close() the selection fd if we didn't start writing yet If the other peer requests data too fast (too rare/unlikely though), we might receive multiple gdk_wayland_selection_request_target() calls with no ending gdk_wayland_selection_check_write(), in which case the fd is leaked as no GOutputStream was created to take over it. https://bugzilla.gnome.org/show_bug.cgi?id=751414 --- gdk/wayland/gdkselection-wayland.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c index 86bfde21a2..c5d0089579 100644 --- a/gdk/wayland/gdkselection-wayland.c +++ b/gdk/wayland/gdkselection-wayland.c @@ -567,6 +567,13 @@ gdk_wayland_selection_request_target (GdkWaylandSelection *wayland_selection, wayland_selection->source_requested_target == target) return FALSE; + /* If we didn't issue gdk_wayland_selection_check_write() yet + * on a previous fd, it will still linger here. Just close it, + * as we can't have more than one fd on the fly. + */ + if (wayland_selection->stored_selection.fd >= 0) + close (wayland_selection->stored_selection.fd); + wayland_selection->stored_selection.fd = fd; wayland_selection->source_requested_target = target; -- 2.30.2